package com.ruoyi.web.wuliu.service.impl;

import java.util.List;

import com.ruoyi.app.utils.AppUserUtils;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.web.wuliu.domain.AppUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.web.wuliu.mapper.CarSourceMapper;
import com.ruoyi.web.wuliu.domain.CarSource;
import com.ruoyi.web.wuliu.service.ICarSourceService;

/**
 * 车辆发布Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-12-05
 */
@Service
public class CarSourceServiceImpl implements ICarSourceService 
{
    @Autowired
    private CarSourceMapper carSourceMapper;

    /**
     * 查询车辆发布
     * 
     * @param id 车辆发布主键
     * @return 车辆发布
     */
    @Override
    public CarSource selectCarSourceById(Integer id)
    {
        return carSourceMapper.selectCarSourceById(id);
    }

    /**
     * 查询车辆发布列表
     * 
     * @param carSource 车辆发布
     * @return 车辆发布
     */
    @Override
    public List<CarSource> selectCarSourceList(CarSource carSource)
    {
        return carSourceMapper.selectCarSourceList(carSource);
    }

    /**
     * 新增车辆发布
     * 
     * @param carSource 车辆发布
     * @return 结果
     */
    @Override
    public int insertCarSource(CarSource carSource)
    {
        AppUser appUser = AppUserUtils.getAppUser();
        carSource.setCreateTime(DateUtils.getNowDate());
        carSource.setUserId(appUser.getId());
        return carSourceMapper.insertCarSource(carSource);
    }

    /**
     * 修改车辆发布
     * 
     * @param carSource 车辆发布
     * @return 结果
     */
    @Override
    public int updateCarSource(CarSource carSource)
    {
        carSource.setUpdateTime(DateUtils.getNowDate());
        return carSourceMapper.updateCarSource(carSource);
    }

    /**
     * 批量删除车辆发布
     * 
     * @param ids 需要删除的车辆发布主键
     * @return 结果
     */
    @Override
    public int deleteCarSourceByIds(Integer[] ids)
    {
        return carSourceMapper.deleteCarSourceByIds(ids);
    }

    /**
     * 删除车辆发布信息
     * 
     * @param id 车辆发布主键
     * @return 结果
     */
    @Override
    public int deleteCarSourceById(Integer id)
    {
        return carSourceMapper.deleteCarSourceById(id);
    }
}
